package logic

import (
	"context"
	"github.com/pkg/errors"
	"technician_srv/model/mysql"

	"technician_srv/internal/svc"
	"technician_srv/technician"

	"github.com/zeromicro/go-zero/core/logx"
)

type FindOneInfoByIdTechnicianLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewFindOneInfoByIdTechnicianLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindOneInfoByIdTechnicianLogic {
	return &FindOneInfoByIdTechnicianLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *FindOneInfoByIdTechnicianLogic) FindOneInfoByIdTechnician(in *technician.FindOneInfoByIdTechnicianRequest) (*technician.TechnicianInfoResponse, error) {
	// todo: add your logic here and delete this line
	m := mysql.Technician{}

	err := m.TechnicianOneInfo(int(in.Id))
	if err != nil {
		return nil, errors.New("技师不存在")
	}

	return &technician.TechnicianInfoResponse{
		Name:   m.Name,
		Cover:  int64(m.Cover),
		Mobile: m.Mobile,
		Age:    int64(m.Age),
		City:   int64(m.City),
	}, nil
}
